#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <malloc.h>

int removeElement(int *nums, int numsSize, int val) {
    int left = 0, right = numsSize;
    while (left < right) {
        if (*(nums + left) == val) {
            //用右数据覆盖左数据，将所有与目标重复的数据都移到右侧
            *(nums + left) = *(nums + right - 1);
            right--;
        } else {
            left++;
        }
    }
    return left;
}

char pairs(char a) {
    if (a == '}') return '{';
    if (a == ']') return '[';
    if (a == ')') return '(';
    return 0;
}

bool isValid(char *s) {
    char c[strlen(s) / 2 + 1];
    int i = 0, j = 0;
    while (i < (strlen(s) / 2 + 1) && j < strlen(s)) {
        c[i] = s[j];
        if (i > 0) {
            //判断符号是否左右匹配
            if (pairs(c[i]) == c[i - 1]) {
                i--;
            } else {
                i++;
            }
        } else {
            i++;
        }
        j++;
    }
    return (j > strlen(s) - 1) && i == 0 ? true : false;
}

bool checkRecord(char *s) {
    int n = 0;
    int m = 0;
    for (int i = 0; i < strlen(s); ++i) {
        if (s[i] == 'A') {
            n++;
            if (n >= 2) return false;
        }
        if (s[i] == 'L') {
            for (int j = i; j < strlen(s) && j < i + 3; ++j) {
                if (s[j] == 'L') { m++; }
                else { m = 0; }
            }
            if (m >= 3) return false;
            m = 0;
        }
    }
    return true;
}

bool isPalindrome(int x) {
    if (x < 0) return false;
    int arr[10];
    int i = 0;
    int flag = 0;
    while (1) {
        arr[i] = x % 10;
        x = x / 10;
        ++i;
        if (x < 10) flag++;
        if (flag > 1 || x <= 0) break;
    }
    for (int j = 0; j < i - 1; ++j) {
        if (arr[j] != arr[i - j - 1]) return false;
    }
    return true;
}

int romanToInt(char *s) {
    int num = 0;
    for (int i = 0; i < strlen(s); ++i) {
        if (*(s + i) == 'I' && *(s + i + 1) == 'V') {
            num += 4;
            i++;
        } else if (*(s + i) == 'I' && *(s + i + 1) == 'X') {
            num += 9;
            i++;
        } else if (*(s + i) == 'X' && *(s + i + 1) == 'L') {
            num += 40;
            i++;
        } else if (*(s + i) == 'X' && *(s + i + 1) == 'C') {
            num += 90;
            i++;
        } else if (*(s + i) == 'C' && *(s + i + 1) == 'D') {
            num += 400;
            i++;
        } else if (*(s + i) == 'C' && *(s + i + 1) == 'M') {
            num += 900;
            i++;
        } else {
            if (*(s + i) == 'I') num += 1;
            if (*(s + i) == 'V') num += 5;
            if (*(s + i) == 'X') num += 10;
            if (*(s + i) == 'L') num += 50;
            if (*(s + i) == 'C') num += 100;
            if (*(s + i) == 'D') num += 500;
            if (*(s + i) == 'M') num += 1000;
        }
    }
    return num;
}


char *longestCommonPrefix(char **strs, int strsSize) {
    static char arr[200];
    for (int i = 0; i < strsSize; ++i) {
        for (int j = 0; j < strlen(*(strs + i)); ++j) {
            if (*(*(strs + i) + j) != *(*(strs + i + 1) + j)) {
                if (j == 0) return "";
                break;
            } else {
                *(arr + j) = *(*(strs + i) + j);
            }
        }
    }
    return arr;
}

int search(int *nums, int numsSize, int target) {
    //二分搜索算法
    int left = 0, right = numsSize - 1;
    if (nums[left] == target) return left;
    if (nums[right] == target) return right;
    while (left <= right) {
        if (nums[(left + right) / 2] == target) return (left + right) / 2;
        if (nums[(left + right) / 2] > target) right = (left + right) / 2 - 1;
        else if (nums[(left + right) / 2] < target) left = (left + right) / 2 + 1;
    }
    return -1;
}

void test() {
    // 请在此输入您的代码
    int T;
    scanf("%d", &T);
    char *str = malloc(sizeof(char) * 4 * T);
    for (int i = 1; i <= T; ++i) {
        scanf("%s", str);
    }
    for (int i = 0; i < strlen(str); i = i + 4) {
        if (str[i] != str[i + 1] && str[i] != str[i + 2] && str[i + 1] != str[i + 2]) {
            printf("No\n");
            break;
        }
        if (str[i] == str[i + 1] && str[i] == str[i + 2] && str[i + 1] == str[i + 2] && str[i] != str[i + 3]) {
            printf("Yes\n");
            break;
        }
        if (str[i] == str[i + 1] && str[i] == str[i + 2] && str[i + 1] == str[i + 2] && str[i] == str[i + 3]) {
            printf("No\n");
            break;
        }
        int m = 0;
        if (str[i] == str[i + 1]) m++;
    }
}

int main() {
//    int arr[] = {-1, 0, 3, 5, 9, 12}, target = 12;
//    printf("%d", search(arr, 6, target));
    test();
    return 0;
}
